<template>
    <div class="form">
        <section class="body">
            <p class="hedd-text">患者财产状况</p>
            <div class="smallTitle">房产总价值</div>
            <van-field
                v-model="money01"
                :disabled="disabled"
                type="number"
                placeholder="房产总价值(万元)"
                maxlength="10"
            />
            <div class="smallTitle">车产价值</div>
            <van-field
                v-model="money02"
                :disabled="disabled"
                type="number"
                placeholder="车产价值(万元)"
                maxlength="10"
            />
            <div class="smallTitle">是否有社区保险?</div>
            <van-tabs type="card" v-model="tab01">
                <van-tab title="有" name="1" :disabled="disabled"></van-tab>
                <van-tab title="无" name="0" :disabled="disabled"></van-tab>
            </van-tabs>
            <div class="smallTitle">是否有商业保险?</div>
            <van-tabs type="card" v-model="tab02">
                <van-tab title="有" name="1" :disabled="disabled"></van-tab>
                <van-tab title="无" name="0" :disabled="disabled"></van-tab>
            </van-tabs>
            <div class="smallTitle">家庭年收入</div>
            <van-field
                v-model="money03"
                :disabled="disabled"
                type="number"
                placeholder="家庭年收入(万元)"
                maxlength="10"
            />
            <div class="smallTitle">其他资产</div>
            <van-field
                v-model="money04"
                :disabled="disabled"
                type="number"
                placeholder="其他资产(万元)"
                maxlength="10"
            />
            <!-- <van-tabs type="card" v-model="house">
                <van-tab title="有" name="yes">
                    <div class="smallTitle">
                        房产总数量（套）
                        <div class="stepper">
                            <van-stepper v-model="num01" />
                        </div>
                    </div>
                    <van-field
                        v-model="money01"
                        type="number"
                        placeholder="房产总价值(万元)"
                        maxlength="10"
                    />
                    <div class="smallTitle">房产状态</div>
                    <van-tabs type="card" v-model="type">
                        <van-tab title="已变卖" name="Already">
                            <div class="smallTitle">
                                已变卖数量 （套）
                                <div class="stepper">
                                    <van-stepper v-model="num02" />
                                </div>
                            </div>
                            <van-field
                                v-model="money02"
                                type="number"
                                placeholder="已变卖价值(万元)"
                                maxlength="10"
                            />
                        </van-tab>
                        <van-tab title="变卖中" name="Being">
                            <div class="smallTitle">
                                变卖中数量 （套）
                                <div class="stepper">
                                    <van-stepper v-model="num03" />
                                </div>
                            </div>
                            <van-field
                                v-model="money03"
                                type="number"
                                placeholder="变卖中价值(万元)"
                                maxlength="10"
                            />
                        </van-tab>
                        <van-tab title="未变卖" name="none"></van-tab>
                    </van-tabs>
                </van-tab>
                <van-tab title="无" name="no"></van-tab>
            </van-tabs>-->
        </section>
        <footer class="footer">
            <van-button
                type="primary"
                round
                color="linear-gradient(to right, #ff3c3c, #ff5e10)"
                size="large"
                @click="submit"
            >完成</van-button>
        </footer>
    </div>
</template>

<script>
import { Field, Button, Toast, Tab, Tabs, Stepper } from "vant";
import { setInformZengxin, getInformZengxin } from "@/api/api";
export default {
    components: {
        [Field.name]: Field,
        [Button.name]: Button,
        [Tab.name]: Tab,
        [Tabs.name]: Tabs,
        [Stepper.name]: Stepper
    },
    created() {
        if (this.$route.path == "/DetailCondition") {
            this.again = true;
            getInformZengxin({ prepare_id: this.$route.query.id }).then(res => {
                if (res.code && res.results.house_worth) {
                    this.disabled = true;
                    let data = res.results;
                    this.money02 = data.vehicle_worth;
                    this.money01 = data.house_worth;
                    this.tab01 = data.is_community_insurance;
                    this.tab02 = data.is_commercial_insurance;
                    this.money03 = data.family_income;
                    this.money04 = data.other_worth;
                }
            });
        }
    },
    data() {
        return {
            // house: "no",
            // num01: "",
            // type: "none",
            // num02: "",
            // num03: "",
            // money03: ""
            money01: "",
            money02: "",
            money03: "",
            money04: "",
            tab01: "0",
            tab02: "0",
            again: false,
            disabled: false
        };
    },
    methods: {
        submit() {
            if (this.disabled) {
                this.$router.push({
                    path: "/DetailInfo",
                    query: { id: this.$route.query.id }
                });
                return false;
            }
            if (this.money01 == "") {
                Toast("请输入房产总价值");
                return false;
            }
            if (this.money02 == "") {
                Toast("请输入车产价值");
                return false;
            }
            if (this.money03 == "") {
                Toast("请输入家庭年收入");
                return false;
            }
            setInformZengxin({
                prepare_id: this.$route.query.id,
                vehicle_worth: this.money02,
                house_worth: this.money01,
                is_community_insurance: this.tab01,
                is_commercial_insurance: this.tab02,
                family_income: this.money03,
                other_worth: this.money04
            }).then(res => {
                if (res.code) {
                    Toast("成功");
                    if (this.again) {
                        this.$router.push({
                            path: "/DetailInfo",
                            query: { id: this.$route.query.id }
                        });
                    } else {
                        this.$router.push({
                            path: "/RaiseFunds"
                        });
                    }
                }
            });
        }
    }
};
</script>

<style scoped>
.body {
    padding-bottom: 70px;
}
.smallTitle {
    display: flex;
    justify-content: space-between;
    margin: 8px 0 14px;
    height: 24px;
    align-items: center;
    font-size: 14px;
    font-family: PingFangSC-Semibold;
    font-weight: bold;
    color: rgba(0, 0, 0, 0.8);
    line-height: 20px;
}
.stepper {
    font-weight: 400;
}
</style>